;
(function($) {
	$.fn.extend({
		"fade": function(autoTime) {
			var  autoTime = autoTime || 5000;
			var $pageBox = $(this);
			var $pageSlide = $pageBox.find(".slideBox .pageSlide");
			var $prevBtn = $pageBox.find(".prevBtn");
			var $nextBtn = $pageBox.find(".nextBtn");
			var $pointLiList = $pageBox.find(".pointList li");
			var len = $pageSlide.length;
			var currentIndex = 0;
			var timer = "";
			
			for (var i = 0; i < len; i++) {
				$pageSlide.eq(i).css("z-index", len - i);
			}

			$pointLiList.on("click", function() {
				var $index = $(this).index();
				currentIndex = $index;
				$(this).addClass("active").siblings().removeClass("active");
				$pageSlide.eq(currentIndex).fadeIn().siblings().fadeOut();
			});

			$nextBtn.on("click", function() {
				currentIndex++;
				if (currentIndex == len) {
					currentIndex = 0;
				}
				$pointLiList.eq(currentIndex).addClass("active").siblings().removeClass("active");
				$pageSlide.eq(currentIndex).fadeIn().siblings().fadeOut();
			});
			$prevBtn.on("click", function() {
				currentIndex--;
				if (currentIndex == -1) {
					currentIndex = len - 1;
				}
				$pointLiList.eq(currentIndex).addClass("active").siblings().removeClass("active");
				$pageSlide.eq(currentIndex).fadeIn().siblings().fadeOut();
			});
			autoPlay();

			function autoPlay() {
				timer = setInterval(function() {
					$nextBtn.click();
				}, autoTime);
			}

			$pageBox.hover(function() {
				clearInterval(timer);
			}, function() {
				autoPlay();
			});

		},
		"slide":function(){
			
		}
	});
})(jQuery);